#include"Comm.hpp"
#include"Fifo.hpp"
#include<unistd.h>
int main()
{
    //获取
 key_t key = Getshmkeyordie();
 std::cout<<"key"<<ToHex(key)<<std::endl;
    
    //创建共享内存
    int shmid = createShm(key,defaultsize);
    std:: cout<<"shmid"<<shmid<<std::endl;

    //将共享内存和进程进行挂接
    char *addr = (char*)ShmAttach(shmid);
    std::cout<<"Attach shm success,addr:"<<ToHex((uint64_t)addr)<<endl;
    

    //先引入管道
    Fifo fifo;
    Sync syn;
    syn.OpenReadOrDie();
    //可疑进程通信
    for(;;)
    {
        if(!syn.Wait())
         {
            break;
         }
         cout<<"shm content"<<addr<<std::endl;
    }
    ShmDetach(addr);
    std::cout<<"Detach shm success,addr: "<<ToHex((uint64_t)addr)<<std::endl;
    //3:删除共享内存
    Deleteshm(shmid);
    return 0;
}